﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using System.Web.Script.Serialization;
using XWG.Framework.AuthUtility;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using JWBSTAPP.CommonClass;
using XWG.Framework.AuthSPConst;
using XWG.JWBST.JWBSTSPConst;

namespace JWBSTAPP.AjaxServer.user
{
    /// <summary>
    /// ImageMenu 的摘要说明
    /// </summary>
    public class ImageMenu : HttpHandlerBase, System.Web.SessionState.IRequiresSessionState
    {

        #region 获取功能数列表(Tree)
        /// <summary>
        /// 获取组织机构列表
        /// </summary>
        public void GetResTree()
        {
            List<TreeNode> treeList = new List<TreeNode>();
            XWG.Framework.IAuthority.IAuth auth = new XWG.Framework.IAuthority.Authority();
            DataTable dtParent = auth.SelectUserResImagePermission(Global.AreaID, XWG.JWBST.JWBSTSPConst.ExDictionayType.resImageType.resImageSmall, Convert.ToString(HttpContext.Current.Session["UserID"]));

            if (dtParent != null || dtParent.Rows.Count > 0)
            {
                for (int i = 0; i < dtParent.Rows.Count; i++)
                {

                    TreeNode tempTree = new TreeNode();
                    tempTree.icon = (string)dtParent.Rows[i][AppImageConst.Columns.ImageValue];
                    tempTree.@checked = false;
                    tempTree.click = string.Empty;
                    tempTree.iconClose = string.Empty;
                    tempTree.iconOpen = string.Empty;
                    tempTree.id = (string)dtParent.Rows[i][AppResouRceConst.Columns.ResId];
                    tempTree.name = (string)dtParent.Rows[i][AppResouRceConst.Columns.ResName];
                    tempTree.pId = (string)dtParent.Rows[i][AppResouRceConst.Columns.ResPid];
                    tempTree.target = "_blank";
                    tempTree.url = (string)dtParent.Rows[i][AppResouRceConst.Columns.ResPvalue];
                    if (tempTree.pId == "0")
                    {
                        tempTree.open = true;
                    }
                    else
                    {
                        tempTree.open = false;
                    }
                    treeList.Add(tempTree);
                }
            }
            string json = JsonConvert.SerializeObject(treeList);
            HttpContext.Current.Response.Write(json);
        }
        #endregion


    }
}